package com.yf.dxapp.module.app.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import com.yf.dxapp.module.app.component.app.QiniuFileComponent;
import com.yf.dxapp.module.app.controller.app.vo.QiniuUpTokenVO;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController
@RequestMapping("/qiniu")
public class ApiAppQiniuController {

    @Value("${Qiniu.url}")
    private String uploadUrl;

    @Resource
    private QiniuFileComponent qiniuFileComponent;


    /**
     * 七牛上传token
     * @return
     */
    @PostMapping("/token")
    public CommonResult qiniu(){
        String token = qiniuFileComponent.getToken();
        return success(new QiniuUpTokenVO(token,3600L,uploadUrl));
    }


}
